package com.linzm.structuraltype.flyweight07.shape;

/**
 * @Author zimingl
 * @Date 2023/4/16 1:49
 * @Description: Circle
 */
public class Circle implements Shape {
    private String color;
    private int x;
    private int y;
    private int radius;

    public Circle(String color) {
        this.color = color;
    }

    private Circle() {

    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void setRadius(int radius) {
        this.radius = radius;
    }

    @Override
    public void draw() {
        System.out.println("Circle: Draw() [Color : " + color
                + ", x : " + x + ", y :" + y + ", radius :" + radius);
    }

    /**
     * 静态内部类 new 对象
     */
    private static class SingletonInstance {
        private final static Circle SINGLETON_CIRCLE = new Circle();
    }

    public static Circle getSingletonInstance() {
        return SingletonInstance.SINGLETON_CIRCLE;
    }
}
